package bean;

import java.sql.Date;
import java.util.ArrayList;

/**
 * Bean object for storage of items from the AuctionItem table within the database, contains getters and setters.
 *
 * @author Sander Meijer & Stijn Kliemesch
 *
 */
public class AuctionItemBean {

	private int auctionItemID;
	private String title;
	private String description;
	private int startPrice;
	private Date startDate;
	private long endTime;
	private int userID;
	private ArrayList<BidBean> bids;
	private String owner;
	private BidBean topBid;
	private BidBean yourTopBid;

	/**
	 * <b>Constructor</b></br>
	 * Creates an empty {@link AuctionItemBean}
	 */
	public AuctionItemBean() {
		bids = new ArrayList<BidBean>();
		topBid = new BidBean();
	}

	/**
	 * <b>Constructor</b></br>
	 * Creates an {@link AuctionItemBean} with the following parameters.
	 * @param the_itemID int
	 * @param the_title String
	 * @param the_description String
	 * @param the_startPrice int
	 * @param the_startDate {@link Date}
	 * @param the_EndTime {@link Date}
	 * @param the_user int
	 * @param the_bids ArrayList {@link BidBean}
	 */
	public AuctionItemBean(int the_itemID, String the_title,
			String the_description, int the_startPrice, Date the_startDate, long the_EndTime,
			int the_user, ArrayList<BidBean> the_bids, BidBean the_topBid) {

		auctionItemID = the_itemID;
		title = the_title;
		description = the_description;
		startPrice = the_startPrice;
		startDate = the_startDate;
		endTime = the_EndTime;
		userID = the_user;
		bids = the_bids;
		topBid = the_topBid;
	}

	public int 					getAuctionItemID()	{ return auctionItemID;	}
	public String 				getTitle() 			{ return title;			}
	public String 				getDescription() 	{ return description;	}
	public int					getStartPrice()		{ return startPrice;	}
	public Date 				getStartDate() 		{ return startDate;		}
	public long 				getEndTime() 		{ return endTime;		}
	public int 					getUserID()			{ return userID;		}
	public ArrayList<BidBean>	getBids()			{ return bids;			}
	public String				getOwner()			{ return owner;			}
	public BidBean				getTopBid()			{ return topBid;		}
	public BidBean				getYourTopBid()		{ return yourTopBid;	}

	public void setAuctionItemID	(int auctionItemID) 		{ this.auctionItemID	= auctionItemID;	}
	public void setTitle			(String title) 				{ this.title 			= title;			}
	public void setDescription		(String description)		{ this.description		= description;		}
	public void setStartPrice		(int startPrice)			{ this.startPrice 		= startPrice;		}
	public void setStartDate		(Date startDate) 			{ this.startDate 		= startDate;		}
	public void setEndTime			(long endTime) 				{ this.endTime			= endTime;			}
	public void setUserID			(int userID) 				{ this.userID 			= userID;			}
	public void setBids				(ArrayList<BidBean> bids )	{ this.bids 			= bids;				}
	public void setOwner			(String owner)				{ this.owner			= owner;			}
	public void setTopBid			(BidBean topBid)			{ this.topBid			= topBid;			}
	public void setYourTopBid		(BidBean yourTopBid)		{ this.yourTopBid		= yourTopBid;		}

	/**
	 * ToString method, returns a string with all the information within this {@link AuctionItemBean}
	 * @return String
	 */
	public String toString() {
		String retString =  "AuctionID: " + auctionItemID + " title: " + title
				+ " description: " + description + " startdate: " + startDate
				+ " endtime: " + endTime + " owner " + userID + "(" + owner + ")\nTop bid: " + topBid 
				+ "\nyourtopBId " + yourTopBid + "\nbids:";
		
		for(BidBean bb : bids){
			retString += "\n\t" + bb.toString();
		}
		
		return retString;
	}
}
